/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.


See LICENSE and AUTHORS for more information.
*/

#include "inputedit.h"
#include <QDebug>

/**
* @brief construct new InputEdit (QTextEdit) and set max size to be one line only
* @param parent optional QWidget parent
*/
InputEdit::InputEdit(QWidget *parent)
    : QTextEdit(parent)
{
    this->setMaximumSize(QSize(16777215,28));        
    
}

/**
* @brief KeyEvent-Handler, called whenever a key is pressed
*
* We intercept the keyPressed-Handler so we can send 
* the message when Return is pressed. All other keys
* are processed as usual.
* @param event the KeyEvent that raised this handler
*/
void InputEdit::keyPressEvent ( QKeyEvent * event  ) 
{
    if (event->key() == Qt::Key_Return)
    {
        // this signal will send the message and clear the inputEdit
	event->accept();
        emit(prepareMsg());
        return;
    }
    // process as usual
    return QTextEdit::keyPressEvent(event);
}



